import { network } from '@/utils';
import {
  DetailParams,
  FranchiseeParams,
  GardensByPhoneParams,
  GardensByNameParams,
} from './data';

import { partner } from '../../../../../config/Apis';

export async function queryFranchiseeDetail(params: DetailParams) {
  params._content_type = 'json';
  return network.get(partner.franchisee_detail, { params });
}

export async function queryFranchiseeList(params: FranchiseeParams) {
  params.has_root = 1;
  params.limit = 20;
  return network.get(partner.franchisee_search, { params });
}

export async function queryGardensByPhone(params: GardensByPhoneParams) {
  return network.get(partner.franchisee_get_gardens_by_phone, { params });
}

export async function queryGardensByName(params: GardensByNameParams) {
  params._content_type = 'json';
  return network.get(partner.franchisee_search_garden, { params });
}

export async function saveFranchisee(params: any) {
  return network.post(params.id ? partner.franchisee_update : partner.franchisee_save, {
    params,
  });
}
